<?php
require_once 'buildCurl.php';

$res = json_decode(file_get_contents('php://input'), true);

$url = "http://211.82.48.36/indexCalendar";
$session = $res['session'];

$myCurl = new MyCurl($url, $session);
$result = $myCurl->getResult();
$httpCode = $myCurl->getHttpCode();

if ($httpCode != 200) {
    $arr = array('err' => 1);
    exit(json_encode($arr));
}

$xqm = explode('xqm = "', $result)[1];
$xqm = explode('"', $xqm)[0];

$currentTime = explode('xnxq = "', $result)[1];
$currentTime = explode('"', $currentTime)[0] . "学年(" . $xqm . ")"; // 学年日期

$kxrq = explode('var rq = "', $result)[1];
$kxrq = explode('"', $kxrq)[0];  // 开学日期

$skzs = explode('var skzc = "', $result)[1];
$skzs = explode('"', $skzs)[0];  // 上课周数

$arr = array('err' => 0, 'currentTime' => $currentTime, 'kxrq' => $kxrq, 'skzs' => $skzs);
exit(json_encode($arr));
